package com.amigo.online.provider.adv.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.amigo.online.provider.adv.entity.AdvNearbyClickRecord;
import com.amigo.online.provider.adv.mapper.AdvNearbyClickRecordMapper;
import com.amigo.online.provider.adv.service.AdvNearbyClickRecordService;

@Service
public class AdvNearbyClickRecordServiceImpl implements AdvNearbyClickRecordService {

    @Autowired
    AdvNearbyClickRecordMapper advNearbyClickRecordMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) //事物传播机制，当前子事物不影响主事物
    public void recordNearbyAdvClicked(Long advId, String device, Long userId) {
        AdvNearbyClickRecord record = new AdvNearbyClickRecord(advId, userId, device);
        //记录数据
        advNearbyClickRecordMapper.insert(record);
    }

}
